﻿@{
    ViewData["Title"] = "任务计划明细";
}
@using LView.CMS.Models;
@using LView.CMS.Core;
@model LTask;

<div class="layui-row">
    <div class="layui-card" style="padding:10px">
        <div class="layui-card-header"><span title="@Model.Name">@Model.Name</span></div>
        <div class="layui-card-body">
            <input type="hidden" id="taskId" value="@Model.Id" />
            <div class="layui-row">
                <div class="layui-col-xs12">
                    <span>负责人 : @Model.DIR</span>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs2">
                    <span>
                        @{ var taskPeriod = 0;}
                        @if (Model.Category != null)
                        {
                            Model.Category.ForEach(x =>
                            {
                                taskPeriod += x.CategoryPeriodMin;
                            });
                        }
                        总学时 : @taskPeriod (分钟)
                    </span>
                </div>
                <div class="layui-col-xs10">
                    <span>
                        已学学时 : @Math.Round(((1.0 * (int)ViewData["hasStudyPeriod"]) / 60), 2) (分钟)
                    </span>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs2">
                    <span>
                        @{ var taskScore = 0;}
                        @if (Model.Category != null)
                        {
                            Model.Category.ForEach(x =>
                            {
                                taskScore += x.CategoryScore;
                            });
                        }
                        总学分 : @taskScore
                    </span>
                </div>
                <div class="layui-col-xs10">
                    <span>
                        已学学分 : @ViewData["hasGotScore"]
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-row">
    <div class="layui-collapse">
        @foreach (var item in Model.Category)
        {
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">@item.Name</h2>
                @foreach (var course in item.Course)
                {
                    <div class="layui-colla-content layui-show" style="padding-left:50px">
                        <input type="hidden" name="courseId" class="courseId" value="@course.CourseId" />
                        <input type="hidden" class="courseType" value="@course.Type" />
                        <ul>
                            @* localhost:8089/NonIframePage/HtmlPage5.html *@
                            @*
                                传入课程相关信息，课程名称，课程学时，课程文件路径

                                判断课程类型
                                如果是考试
                                {
                                    转到考试页面
                                }
                                如果是文件
                                {
                                    通过文件路径取出文件，判断文件类型，决定播放视频还是PDF/PPT转图片进行显示
                                }
                            *@
                            <li>
                                @* onclick="learningKnowledge('http://localhost:8089/aaaaaaa.html')" *@
                                <span>
                                    <input type="hidden" class="courseCategory" value="@item.Name" />
                                    <input type="hidden" class="courseTask" value="@Model.Name" />
                                    教程@(item.Course.IndexOf(course)+1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@if (course.Type == "0")
                                    {
                                        var courseFile = MongodbHelper.Instance.FindEntity<LFile>(x => x.Id == course.FileId);
                                        <input type="hidden" class="courseFile" value="@courseFile.Path" />
                                        <input type="hidden" class="courseId" value="@course.CourseId" />
                                        <input type="hidden" class="courseFileType" value="@courseFile.Type" />
                                        <input type="hidden" class="courseFileName" value="@courseFile.Name" />
                                        <input type="hidden" class="courseRequiredTime" value="@course.CoursePeriod" />
                                        <input type="hidden" class="courseFileId" value="@courseFile.Id" />
                                        if (courseFile.Type == "Video")
                                        {
                                            <i class="layui-icon">&#xe652;</i>
                                        }
                                        else
                                        {
                                            <i class="layui-icon">&#xe655;</i>
                                        }
                                    }
                                    else
                                    {
                                        var exam = MongodbHelper.Instance.FindEntity<LExam>(x => x.Id == course.ExamId);
                                        <input type="hidden" class="courseExamName" value="@exam.Name" />
                                        <input type="hidden" class="courseExamId" value="@course.ExamId" />
                                        <i class="layui-icon">&#xe6b2;</i>
                                    } @course.Description
                                </span>
                            </li>
                        </ul>
                    </div>
                }
            </div>
        }
    </div>
</div>

@section Scripts{
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script type="text/javascript" src="~/js/MyTask/MyTaskDetail.js?_=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
}
